﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Informant.Contacts;

namespace Informant.Services.Models.Contacts
{
	[DataContract(Name = "Contact")]
	public class Contact : IContact
	{
		/// <summary>
		/// Gets or sets the id.
		/// </summary>
		/// <value>The id.</value>
		[DataMember]
		public String Id { get; set; }
		/// <summary>
		/// Gets or sets the first name.
		/// </summary>
		/// <value>The first name.</value>
		[DataMember]
		public String FirstName { get; set; }
		/// <summary>
		/// Gets or sets the last name.
		/// </summary>
		/// <value>The last name.</value>
		[DataMember]
		public String LastName { get; set; }
		/// <summary>
		/// Gets or sets the addresses.
		/// </summary>
		/// <value>The addresses.</value>
		public IEnumerable<IOrganization> Organizations
		{
			get { return ServiceModelOrganizations.OfType<IOrganization>(); }
			set { ServiceModelOrganizations = value.OfType<Organization>(); }
		}
		/// <summary>
		/// Gets or sets the organizations.
		/// </summary>
		/// <value>The organizations.</value>
		[DataMember]
		public IEnumerable<Organization> ServiceModelOrganizations { get; set; }
		/// <summary>
		/// Gets or sets the addresses.
		/// </summary>
		/// <value>The addresses.</value>
		public IEnumerable<IAddress> Addresses
		{
			get { return ServiceModelAddresses.OfType<IAddress>(); }
			set { ServiceModelAddresses = value.OfType<Address>(); }
		}
		/// <summary>
		/// Gets or sets the addresses.
		/// </summary>
		/// <value>The addresses.</value>
		[DataMember]
		public IEnumerable<Address> ServiceModelAddresses { get; set; }
		/// <summary>
		/// Gets or sets the emails.
		/// </summary>
		/// <value>The emails.</value>
		public IEnumerable<IEmail> Emails
		{
			get { return ServiceModelEmails.OfType<IEmail>(); }
			set { ServiceModelEmails = value.OfType<Email>(); }
		}
		/// <summary>
		/// Gets or sets the emails.
		/// </summary>
		/// <value>The emails.</value>
		[DataMember]
		public IEnumerable<Email> ServiceModelEmails { get; set; }
		/// <summary>
		/// Gets or sets the phones.
		/// </summary>
		/// <value>The phones.</value>
		public IEnumerable<IPhone> Phones
		{
			get { return ServiceModelPhones.OfType<IPhone>(); }
			set { ServiceModelPhones = value.OfType<Phone>(); }
		}
		/// <summary>
		/// Gets or sets the phones.
		/// </summary>
		/// <value>The phones.</value>
		[DataMember]
		public IEnumerable<Phone> ServiceModelPhones { get; set; }
		/// <summary>
		/// Gets or sets the groups.
		/// </summary>
		/// <value>The groups.</value>
		public IEnumerable<IGroup> Groups
		{
			get { return ServiceModelGroups.OfType<IGroup>(); }
			set { ServiceModelGroups = value.OfType<Group>(); }
		}
		/// <summary>
		/// Gets or sets the groups.
		/// </summary>
		/// <value>The groups.</value>
		[DataMember]
		public IEnumerable<Group> ServiceModelGroups { get; set; }
	}
}
